package com.du.cloud.oauth.config;

import com.du.cloud.oauth.util.MD5Util;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * Desc:
 * Author: dushuang
 * Date 2019/12/30 16:46
 */
public class NoEncryptPasswordEncoder implements PasswordEncoder {

    private static final String SALT_KEY = "A07B66CD4641432A8F9E9D81C52A57F2";

    @Override
    public String encode(CharSequence charSequence) {
        return MD5Util.getMd5Value(charSequence + SALT_KEY);
    }

    @Override
    public boolean matches(CharSequence charSequence, String password) {
        return password.contentEquals(encode(charSequence));
    }
}
